<?php

/**
 * printtemplate actions.
 *
 * @package    digitalform
 * @subpackage printtemplate
 * @author     Saul Santiago
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class printtemplateActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    //$this->forward('default', 'module');
  }

  public function executeAssignees(sfWebRequest $request)
  {
    $this->forward404Unless($application_id = $request->getParameter('appId'));
    sfConfig::set('sf_web_debug', false);
    $this->assignees = AssigneeTable::getAssignees($application_id);
    $findApplicationResult = ApplicationCorporateManagedTable::fetchById($application_id);
    $this->forward404Unless(count($findApplicationResult) == 1);
    $this->application = $findApplicationResult[0];
  }

  public function executeApplicationForm(sfWebRequest $request)
  {
    $this->forward404Unless(($application_id = $request->getParameter('appId')) && ($type = $request->getParameter('type')));
    sfConfig::set('sf_web_debug', false);
    switch($type) {
      case 'ci':
        $findApplicationResult = ApplicationCorporateIndividualTable::fetchById($application_id);
        break;
      case 'cm':
        $findApplicationResult = ApplicationCorporateManagedTable::fetchById($application_id);
        break;
    }
    $this->forward404Unless(count($findApplicationResult) == 1);
    $this->type = $type;
    $this->application = $findApplicationResult[0];


//    echo '<pre>';
//    print_r($this->application);
//    echo '</pre>';
//    exit();
  }

}
